package com.qf.dao;

import com.qf.pojo.Developer;
import com.qf.pojo.Project;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * @Description: 公用常量
 * @Data: 2022/8/25 11:09
 * @Pacakge: com.qf.dao
 * @ClassName: DeveloperDao
 * @Author: fan
 * 开发商数据访问接口
 */
public interface DeveloperDao {
    Developer findDeveloperByDid(@Param("did") String did);
    @Select("select * from developer where did = #{did} and status =1")
    Developer findDeveloperByDidByNote(@Param("did")String did);

    /**
     * 查询所有开发商以及其对应的部门
     * @return
     */
    @Results(id = "developerAndBranch",value = {
            @Result(column = "did",property = "did"),
            @Result(column = "dname",property = "dname"),
            @Result(column = "updatetime",property = "updatetime"),
            @Result(column = "status",property = "status"),
            @Result(column = "did",property = "project",javaType = Project.class,
                one = @One(select = "com.qf.dao.ProjectDao.findProjectByDid",
                           fetchType = FetchType.EAGER)
                )
    })
    @Select("select * from developer where status = 1")
    List<Developer> findDeveloperAndBranch();
}
